
// 按钮放大效果
cc.Class({
    extends: cc.Component,

    properties: {
        // 放大倍数
        pressedScale: 0.85,
        // 时延
        transDuration: 0.1
    },


    // 注册按键事件，直接拖拽到button即可
    onLoad () {
        // TODO add audio
        this.inintScale = this.node.scale;
        const scaleDownAction = cc.scaleTo(this.transDuration, this.pressedScale);
        const scaleUpAction = cc.scaleTo(this.transDuration, this.inintScale);
        function onTouchDown(event) {
            this.stopAllActions();
            this.runAction(scaleDownAction);
        }

        function onTouchUp(event) {
            this.stopAllActions();
            this.runAction(scaleUpAction);
        }
        this.node.on(cc.Node.EventType.TOUCH_START, onTouchDown, this.node);
        this.node.on(cc.Node.EventType.TOUCH_CANCEL, onTouchUp, this.node);
        this.node.on(cc.Node.EventType.TOUCH_END, onTouchUp, this.node);
    },

    // update (dt) {},
});
